package com.InfinityRun;

import Objects.OverlapTester;
import Objects.Rectangle;
import Objects.Vector2;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.Log;
import android.view.MotionEvent;

public class MenuScene extends Scene
{
	Paint p;
	Rectangle play;
	Rectangle instructions;
	Bitmap image;
	
	public MenuScene(int w, int h)
	{
		image = Assets.menu;
		screen = new Vector2(w,h);
		play = new Rectangle((screen.x * 0.25f),(screen.y * 0.3f),(int)(screen.x * 0.5f),(int)(screen.y * 0.1f));
		instructions = new Rectangle((screen.x * 0.25f),(screen.y * 0.6f),(int)(screen.x * 0.5f),(int)(screen.y * 0.1f));

		p = new Paint();
		p.setARGB(255, 0, 255, 0);
	}
	
	@Override
	public void Update(float deltaTime) 
	{
		
	}

	@Override
	public void Draw(Canvas c) 
	{
		c.drawRGB(0, 0, 0);
		c.drawBitmap(image,0,0,null);
		p.setARGB(255, 0, 255, 0);
		c.drawRect(play.lowerLeft.x,play.lowerLeft.y,play.lowerLeft.x + play.width,play.lowerLeft.y + play.height, p);
		p.setARGB(255, 255, 0, 0);
		c.drawRect(instructions.lowerLeft.x,instructions.lowerLeft.y,instructions.lowerLeft.x + instructions.width,instructions.lowerLeft.y + instructions.height, p);
	}

	@Override
	public void GetInput(MotionEvent ev) 
	{
		Log.d("testes", "touch: x =" + (int)ev.getX() +  "y = " + (int)ev.getY() );
		if(ev.getAction() == MotionEvent.ACTION_DOWN || ev.getAction() == MotionEvent.ACTION_MOVE)
		{
			if(OverlapTester.pointInRectangle(play, ev.getX(), ev.getY()))
			{
				SceneManager manager = SceneManager.getInstance();
				manager.ChangeScene(2);
			}
			
			if(OverlapTester.pointInRectangle(instructions, ev.getX(), ev.getY()))
			{
				SceneManager manager = SceneManager.getInstance();
				Log.d("testes", "oi");
				manager.ChangeScene(1);
			}
		}
	}

	@Override
	public void OnPause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void OnResume() {
		// TODO Auto-generated method stub
		
	}

}
